<html><head><title>/Users/Alexander/SandBox/nwscode/nwscode/product.py</title>
        <script type="text/javascript"><!--
        
function show_line_range() {
    var href = document.location.href;
    if (href.indexOf('?') == -1) {
        return;
    }
    var qs = href.substring(href.indexOf('?')+1);
    if (qs.indexOf('#') >= 0) {
        qs = qs.substring(0, qs.indexOf('#'));
    }
    var first = qs.match(/f=(\d+)/)[1];
    var last = qs.match(/l=(\d+)/)[1];
    if (! first || ! last) {
        return;
    }
    var anchors = document.getElementsByTagName('A');
    var container = document.createElement('DIV');
    container.className = 'highlighted';
    var children = [];
    var start = null;
    var parent = null;
    var highlight = false;
    for (var i = 0; i < anchors.length; i++) {
        var el = anchors[i];
        if (el.getAttribute('name') == first) {
            start = el.previousSibling;
            parent = el.parentNode;
            highlight = true;
        }
        if (el.getAttribute('name') == last) {
            break;
        }
        if (highlight) {
            children[children.length] = el;
            el = el.nextSibling;
            while (el && el.tagName != 'A') {
                children[children.length] = el;
                el = el.nextSibling;
            }
        }
    }
    for (i=0; i<children.length; i++) {
        container.appendChild(children[i]);
    }
    if (start) {
        start.parentNode.insertBefore(container, start.nextSibling);
    } else {
        parent.insertBefore(container, parent.childNodes[0]);
    }
}

        // --></script>
        <style>
        div.python {
          color: #333
        }
        div.python a.lnum {
          color: #555;
          background-color: #eee;
          border-right: 1px solid #999;
          padding-right: 2px;
          margin-right: 4px;
        }
        div.python span.comment { color: #933 }
        div.python span.keyword { color: #a3e; font-weight: bold  }
        div.python span.op { color: #c96 }
        div.python span.string { color: #6a6 }
        div.python span.name { }
        div.python span.text { color: #333 }
        div.highlighted { background-color: #ff9; border: 1px solid #009 }
        </style></head><body onload="show_line_range()"><div class="python"><code><a class="lnum" href="#1" name="1">0001</a><span class="comment">#!/usr/bin/env&#0160;python</span><br />
<a class="lnum" href="#2" name="2">0002</a><span class="comment"></span><span class="comment">#&#0160;encoding:&#0160;utf-8</span><br />
<a class="lnum" href="#3" name="3">0003</a><span class="comment"></span><span class="string">"""</span><br />
<a class="lnum" href="#4" name="4">0004</a><span class="string">Tools&#0160;for&#0160;working&#0160;with&#0160;NWS&#0160;product&#0160;texts.</span><br />
<a class="lnum" href="#5" name="5">0005</a><span class="string"></span><br />
<a class="lnum" href="#6" name="6">0006</a><span class="string">Created&#0160;by&#0160;Alexander&#0160;Ross&#0160;on&#0160;2006-07-17.</span><br />
<a class="lnum" href="#7" name="7">0007</a><span class="string">Copyright&#0160;(c)&#0160;2006&#0160;NOAA's&#0160;National&#0160;Weather&#0160;Service.&#0160;All&#0160;rights&#0160;reserved.</span><br />
<a class="lnum" href="#8" name="8">0008</a><span class="string">"""</span><br />
<a class="lnum" href="#9" name="9">0009</a><br />
<a class="lnum" href="#10" name="10">0010</a><span class="keyword">import</span>&#0160;<span class="name">re</span><br />
<a class="lnum" href="#11" name="11">0011</a><br />
<a class="lnum" href="#12" name="12">0012</a><span class="keyword">from</span>&#0160;<span class="name">nwscode</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">NwsCode</span><br />
<a class="lnum" href="#13" name="13">0013</a><span class="keyword">from</span>&#0160;<span class="name">wmo</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">WmoHeader</span><br />
<a class="lnum" href="#14" name="14">0014</a><span class="keyword">from</span>&#0160;<span class="name">awipsid</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">AwipsId</span><br />
<a class="lnum" href="#15" name="15">0015</a><span class="keyword">from</span>&#0160;<span class="name">ugc</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">Ugc</span><br />
<a class="lnum" href="#16" name="16">0016</a><span class="keyword">from</span>&#0160;<span class="name">pvtec</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">Pvtec</span><br />
<a class="lnum" href="#17" name="17">0017</a><span class="keyword">from</span>&#0160;<span class="name">hvtec</span>&#0160;<span class="keyword">import</span>&#0160;<span class="name">Hvtec</span><br />
<a class="lnum" href="#18" name="18">0018</a><br />
<a class="lnum" href="#19" name="19">0019</a><span class="keyword">class</span>&#0160;<span class="name">ProductError</span><span class="op">(</span><span class="name">Exception</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#20" name="20">0020</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">pass</span><br />
<a class="lnum" href="#21" name="21">0021</a><br />
<a class="lnum" href="#22" name="22">0022</a><span class="keyword">class</span>&#0160;<span class="name">Product</span>&#0160;<span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#23" name="23">0023</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#24" name="24">0024</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">text</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="name">replace</span><span class="op">(</span><span class="string">"\r\n"</span><span class="op">,</span>&#0160;<span class="string">"\n"</span><span class="op">)</span><br />
<a class="lnum" href="#25" name="25">0025</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">m</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Ugc</span><span class="op">.</span><span class="name">pattern</span><span class="op">.</span><span class="name">search</span><span class="op">(</span><span class="name">text</span><span class="op">)</span><br />
<a class="lnum" href="#26" name="26">0026</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">m</span><span class="op">:</span><br />
<a class="lnum" href="#27" name="27">0027</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ProductError</span><span class="op">(</span><span class="string">"Product&#0160;does&#0160;not&#0160;contain&#0160;a&#0160;UGC&#0160;code."</span><span class="op">)</span><br />
<a class="lnum" href="#28" name="28">0028</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">header</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Header</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">[</span><span class="op">:</span><span class="name">m</span><span class="op">.</span><span class="name">start</span><span class="op">(</span><span class="op">)</span><span class="op">]</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#29" name="29">0029</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">body</span>&#0160;<span class="op">=</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">[</span><span class="name">m</span><span class="op">.</span><span class="name">start</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="op">]</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#30" name="30">0030</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">segments</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
<a class="lnum" href="#31" name="31">0031</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">segment_texts</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Segment</span><span class="op">.</span><span class="name">pattern</span><span class="op">.</span><span class="name">split</span><span class="op">(</span><span class="name">body</span><span class="op">)</span><br />
<a class="lnum" href="#32" name="32">0032</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">footer</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Footer</span><span class="op">(</span><span class="name">segment_texts</span><span class="op">.</span><span class="name">pop</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#33" name="33">0033</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">seg_text</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">segment_texts</span><span class="op">:</span><br />
<a class="lnum" href="#34" name="34">0034</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">events</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
<a class="lnum" href="#35" name="35">0035</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">seg_text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">seg_text</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#36" name="36">0036</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">seg_text</span><span class="op">:</span><br />
<a class="lnum" href="#37" name="37">0037</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">continue</span><br />
<a class="lnum" href="#38" name="38">0038</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
<a class="lnum" href="#39" name="39">0039</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">seg</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Segment</span><span class="op">(</span><span class="name">seg_text</span><span class="op">)</span><br />
<a class="lnum" href="#40" name="40">0040</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span>&#0160;<span class="name">SegmentError</span><span class="op">:</span><br />
<a class="lnum" href="#41" name="41">0041</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">pass</span><br />
<a class="lnum" href="#42" name="42">0042</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">else</span><span class="op">:</span><br />
<a class="lnum" href="#43" name="43">0043</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">segments</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">seg</span><span class="op">)</span><br />
<a class="lnum" href="#44" name="44">0044</a><br />
<a class="lnum" href="#45" name="45">0045</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__str__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#46" name="46">0046</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">lines</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">header</span><span class="op">)</span><span class="op">]</span><br />
<a class="lnum" href="#47" name="47">0047</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">segments</span><span class="op">:</span><br />
<a class="lnum" href="#48" name="48">0048</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">lines</span><span class="op">.</span><span class="name">extend</span><span class="op">(</span><span class="op">[</span><span class="name">str</span><span class="op">(</span><span class="name">ev</span><span class="op">)</span>&#0160;<span class="keyword">for</span>&#0160;<span class="name">ev</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">segments</span><span class="op">]</span><span class="op">)</span><br />
<a class="lnum" href="#49" name="49">0049</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">lines</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">footer</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#50" name="50">0050</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'\n'</span><span class="op">.</span><span class="name">join</span><span class="op">(</span><span class="name">lines</span><span class="op">)</span><br />
<a class="lnum" href="#51" name="51">0051</a><br />
<a class="lnum" href="#52" name="52">0052</a><br />
<a class="lnum" href="#53" name="53">0053</a><span class="keyword">class</span>&#0160;<span class="name">Header</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#54" name="54">0054</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
<a class="lnum" href="#55" name="55">0055</a><span class="string">&#0160;&#0160;&#0160;&#0160;``Product&#0160;Header``</span><br />
<a class="lnum" href="#56" name="56">0056</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
<a class="lnum" href="#57" name="57">0057</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#58" name="58">0058</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">text</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#59" name="59">0059</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">text</span><span class="op">.</span><span class="name">split</span><span class="op">(</span><span class="string">"\n"</span><span class="op">)</span><br />
<a class="lnum" href="#60" name="60">0060</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">try</span><span class="op">:</span><br />
<a class="lnum" href="#61" name="61">0061</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">wmo</span>&#0160;<span class="op">=</span>&#0160;<span class="name">WmoHeader</span><span class="op">(</span><span class="name">text</span><span class="op">[</span><span class="number">0</span><span class="op">]</span><span class="op">)</span><br />
<a class="lnum" href="#62" name="62">0062</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">awipsid</span>&#0160;<span class="op">=</span>&#0160;<span class="name">AwipsId</span><span class="op">(</span><span class="name">text</span><span class="op">[</span><span class="number">1</span><span class="op">]</span><span class="op">)</span><br />
<a class="lnum" href="#63" name="63">0063</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">except</span><span class="op">:</span><br />
<a class="lnum" href="#64" name="64">0064</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">ProductError</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#65" name="65">0065</a><br />
<a class="lnum" href="#66" name="66">0066</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__str__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#67" name="67">0067</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span><br />
<a class="lnum" href="#68" name="68">0068</a><br />
<a class="lnum" href="#69" name="69">0069</a><br />
<a class="lnum" href="#70" name="70">0070</a><span class="keyword">class</span>&#0160;<span class="name">Footer</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#71" name="71">0071</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#72" name="72">0072</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">text</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#73" name="73">0073</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__str__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#74" name="74">0074</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span><br />
<a class="lnum" href="#75" name="75">0075</a><br />
<a class="lnum" href="#76" name="76">0076</a><br />
<a class="lnum" href="#77" name="77">0077</a><span class="keyword">class</span>&#0160;<span class="name">SegmentError</span><span class="op">(</span><span class="name">ProductError</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#78" name="78">0078</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">pass</span><br />
<a class="lnum" href="#79" name="79">0079</a><br />
<a class="lnum" href="#80" name="80">0080</a><span class="name">SEGMENT</span>&#0160;<span class="op">=</span>&#0160;<span class="string">r"^\$\$$"</span><br />
<a class="lnum" href="#81" name="81">0081</a><span class="keyword">class</span>&#0160;<span class="name">Segment</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#82" name="82">0082</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""&#0160;Segment&#0160;wraps&#0160;a&#0160;text&#0160;segment.</span><br />
<a class="lnum" href="#83" name="83">0083</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#84" name="84">0084</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;Attribute:</span><br />
<a class="lnum" href="#85" name="85">0085</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#86" name="86">0086</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``ugc``</span><br />
<a class="lnum" href="#87" name="87">0087</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;ugc&#0160;code&#0160;for&#0160;this&#0160;segment.</span><br />
<a class="lnum" href="#88" name="88">0088</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#89" name="89">0089</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``text``</span><br />
<a class="lnum" href="#90" name="90">0090</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;the&#0160;actual&#0160;segment&#0160;text.</span><br />
<a class="lnum" href="#91" name="91">0091</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#92" name="92">0092</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``events``</span><br />
<a class="lnum" href="#93" name="93">0093</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;a&#0160;list&#0160;of&#0160;any&#0160;events&#0160;in&#0160;the&#0160;segment.</span><br />
<a class="lnum" href="#94" name="94">0094</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#95" name="95">0095</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``forecasts``</span><br />
<a class="lnum" href="#96" name="96">0096</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;list&#0160;of&#0160;forecasts&#0160;in&#0160;the&#0160;segment.&#0160;&#0160;Ordered&#0160;nearest&#0160;to&#0160;farthest</span><br />
<a class="lnum" href="#97" name="97">0097</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;from&#0160;now.</span><br />
<a class="lnum" href="#98" name="98">0098</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#99" name="99">0099</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;``headlines``</span><br />
<a class="lnum" href="#100" name="100">0100</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;list&#0160;of&#0160;headlines&#0160;in&#0160;the&#0160;segment.</span><br />
<a class="lnum" href="#101" name="101">0101</a><span class="string">&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;</span><br />
<a class="lnum" href="#102" name="102">0102</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
<a class="lnum" href="#103" name="103">0103</a>&#0160;&#0160;&#0160;&#0160;<span class="name">pattern</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="name">SEGMENT</span><span class="op">,</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">MULTILINE</span><span class="op">|</span><span class="name">re</span><span class="op">.</span><span class="name">DOTALL</span><span class="op">)</span><br />
<a class="lnum" href="#104" name="104">0104</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#105" name="105">0105</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span>&#0160;<span class="op">=</span>&#0160;<span class="name">text</span><br />
<a class="lnum" href="#106" name="106">0106</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;parse&#0160;events.</span><br />
<a class="lnum" href="#107" name="107">0107</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">events</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
<a class="lnum" href="#108" name="108">0108</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">m</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Ugc</span><span class="op">.</span><span class="name">pattern</span><span class="op">.</span><span class="name">search</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">)</span><br />
<a class="lnum" href="#109" name="109">0109</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="keyword">not</span>&#0160;<span class="name">m</span><span class="op">:</span><br />
<a class="lnum" href="#110" name="110">0110</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">SegmentError</span><span class="op">(</span><span class="string">"Segment&#0160;does&#0160;not&#0160;have&#0160;a&#0160;UGC&#0160;code."</span><span class="op">)</span><br />
<a class="lnum" href="#111" name="111">0111</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">ugc</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Ugc</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">[</span><span class="name">m</span><span class="op">.</span><span class="name">start</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="name">m</span><span class="op">.</span><span class="name">end</span><span class="op">(</span><span class="op">)</span><span class="op">]</span><span class="op">)</span><br />
<a class="lnum" href="#112" name="112">0112</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">line</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">.</span><span class="name">split</span><span class="op">(</span><span class="string">'\n'</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#113" name="113">0113</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">Pvtec</span><span class="op">.</span><span class="name">pattern</span><span class="op">.</span><span class="name">match</span><span class="op">(</span><span class="name">line</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#114" name="114">0114</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">events</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">Event</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">ugc</span><span class="op">,</span>&#0160;<span class="name">Pvtec</span><span class="op">(</span><span class="name">line</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#115" name="115">0115</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">Hvtec</span><span class="op">.</span><span class="name">pattern</span><span class="op">.</span><span class="name">match</span><span class="op">(</span><span class="name">line</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#116" name="116">0116</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">events</span><span class="op">[</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><span class="op">.</span><span class="name">hvtec</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Hvtec</span><span class="op">(</span><span class="name">line</span><span class="op">)</span><br />
<a class="lnum" href="#117" name="117">0117</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;parse&#0160;forecasts.</span><br />
<a class="lnum" href="#118" name="118">0118</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">forecasts</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
<a class="lnum" href="#119" name="119">0119</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">fcst_pat</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r"(?m)^\.[A-Z&#0160;]+?[\.]{3}.*(?:\n(?:[A-Z0-9].*)*)*"</span><span class="op">)</span><br />
<a class="lnum" href="#120" name="120">0120</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">m</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">fcst_pat</span><span class="op">.</span><span class="name">finditer</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#121" name="121">0121</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">fcst</span>&#0160;<span class="op">=</span>&#0160;<span class="name">m</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><span class="op">.</span><span class="name">replace</span><span class="op">(</span><span class="string">"\n"</span><span class="op">,</span>&#0160;<span class="string">"&#0160;"</span><span class="op">)</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#122" name="122">0122</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">forecasts</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">fcst</span><span class="op">)</span><br />
<a class="lnum" href="#123" name="123">0123</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;parse&#0160;headlines.</span><br />
<a class="lnum" href="#124" name="124">0124</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">headlines</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="op">]</span><br />
<a class="lnum" href="#125" name="125">0125</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline_pat</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r"(?ms)^[\.]{3}[A-Z0-9&#0160;\n]*[\.]{3}$"</span><span class="op">)</span><br />
<a class="lnum" href="#126" name="126">0126</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">m</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">headline_pat</span><span class="op">.</span><span class="name">finditer</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#127" name="127">0127</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">m</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><span class="op">.</span><span class="name">replace</span><span class="op">(</span><span class="string">"\n"</span><span class="op">,</span>&#0160;<span class="string">"&#0160;"</span><span class="op">)</span><span class="op">.</span><span class="name">strip</span><span class="op">(</span><span class="op">)</span><br />
<a class="lnum" href="#128" name="128">0128</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">headlines</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">headline</span><span class="op">)</span><br />
<a class="lnum" href="#129" name="129">0129</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;we've&#0160;got&#0160;to&#0160;handle&#0160;short-fuse&#0160;products&#0160;seperately.&#0160;&#0160;These&#0160;don't</span><br />
<a class="lnum" href="#130" name="130">0130</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="comment">#&#0160;even&#0160;have&#0160;a&#0160;headline&#0160;in&#0160;them&#0160;so&#0160;we&#0160;have&#0160;to&#0160;generate&#0160;them.</span><br />
<a class="lnum" href="#131" name="131">0131</a><span class="comment"></span>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">short_fuse</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">r"(?m)^\*&#0160;(?:SEVERE&#0160;THUNDERSTORM|TORNADO|(?:FLASH&#0160;)?FLOOD)&#0160;(?:WARNING|WATCH|ADVISORY)&#0160;FOR[\.]*(?:\n[A-Z0-9&#0160;.]+)$"</span><span class="op">)</span><br />
<a class="lnum" href="#132" name="132">0132</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">for</span>&#0160;<span class="name">m</span>&#0160;<span class="keyword">in</span>&#0160;<span class="name">short_fuse</span><span class="op">.</span><span class="name">finditer</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">text</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#133" name="133">0133</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">m</span><span class="op">.</span><span class="name">group</span><span class="op">(</span><span class="number">0</span><span class="op">)</span><br />
<a class="lnum" href="#134" name="134">0134</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">headline</span><span class="op">.</span><span class="name">replace</span><span class="op">(</span><span class="string">'\n'</span><span class="op">,</span>&#0160;<span class="string">'&#0160;'</span><span class="op">)</span><br />
<a class="lnum" href="#135" name="135">0135</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">headline</span><span class="op">.</span><span class="name">lstrip</span><span class="op">(</span><span class="string">"*&#0160;"</span><span class="op">)</span><br />
<a class="lnum" href="#136" name="136">0136</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">headline</span><span class="op">.</span><span class="name">replace</span><span class="op">(</span><span class="string">"..."</span><span class="op">,</span>&#0160;<span class="string">""</span><span class="op">)</span><br />
<a class="lnum" href="#137" name="137">0137</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="name">re</span><span class="op">.</span><span class="name">compile</span><span class="op">(</span><span class="string">"&#0160;&#0160;+"</span><span class="op">)</span><span class="op">.</span><span class="name">sub</span><span class="op">(</span><span class="string">'&#0160;'</span><span class="op">,</span>&#0160;<span class="name">headline</span><span class="op">)</span><br />
<a class="lnum" href="#138" name="138">0138</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">headline</span>&#0160;<span class="op">=</span>&#0160;<span class="string">"..."</span>&#0160;<span class="op">+</span>&#0160;<span class="name">headline</span>&#0160;<span class="op">+</span>&#0160;<span class="string">"..."</span><br />
<a class="lnum" href="#139" name="139">0139</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">headlines</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">headline</span><span class="op">)</span><br />
<a class="lnum" href="#140" name="140">0140</a><br />
<a class="lnum" href="#141" name="141">0141</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__str__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#142" name="142">0142</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">text</span><br />
<a class="lnum" href="#143" name="143">0143</a><br />
<a class="lnum" href="#144" name="144">0144</a><br />
<a class="lnum" href="#145" name="145">0145</a><span class="keyword">class</span>&#0160;<span class="name">Event</span><span class="op">(</span><span class="name">object</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#146" name="146">0146</a>&#0160;&#0160;&#0160;&#0160;<span class="string">"""</span><br />
<a class="lnum" href="#147" name="147">0147</a><span class="string">&#0160;&#0160;&#0160;&#0160;``Event``&#0160;wraps&#0160;instances&#0160;of&#0160;a&#0160;UGC,&#0160;a&#0160;PVTEC,&#0160;and&#0160;(optionally)&#0160;an&#0160;HVTEC</span><br />
<a class="lnum" href="#148" name="148">0148</a><span class="string">&#0160;&#0160;&#0160;&#0160;object.&#0160;&#0160;The&#0160;attributes&#0160;of&#0160;each&#0160;of&#0160;those&#0160;objects&#0160;are&#0160;accessible&#0160;through</span><br />
<a class="lnum" href="#149" name="149">0149</a><span class="string">&#0160;&#0160;&#0160;&#0160;the&#0160;Event&#0160;object.&#0160;&#0160;The&#0160;event&#0160;object&#0160;is&#0160;intended&#0160;as&#0160;a&#0160;minimal&#0160;container</span><br />
<a class="lnum" href="#150" name="150">0150</a><span class="string">&#0160;&#0160;&#0160;&#0160;for&#0160;these&#0160;three&#0160;objects.</span><br />
<a class="lnum" href="#151" name="151">0151</a><span class="string">&#0160;&#0160;&#0160;&#0160;"""</span><br />
<a class="lnum" href="#152" name="152">0152</a><br />
<a class="lnum" href="#153" name="153">0153</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__init__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">ugc</span><span class="op">,</span>&#0160;<span class="name">pvtec</span><span class="op">,</span>&#0160;<span class="name">hvtec</span><span class="op">=</span><span class="name">None</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#154" name="154">0154</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">ugc</span>&#0160;<span class="op">=</span>&#0160;<span class="name">ugc</span><br />
<a class="lnum" href="#155" name="155">0155</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">pvtec</span>&#0160;<span class="op">=</span>&#0160;<span class="name">pvtec</span><br />
<a class="lnum" href="#156" name="156">0156</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">self</span><span class="op">.</span><span class="name">hvtec</span>&#0160;<span class="op">=</span>&#0160;<span class="name">hvtec</span><br />
<a class="lnum" href="#157" name="157">0157</a><br />
<a class="lnum" href="#158" name="158">0158</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__getattr__</span><span class="op">(</span><span class="name">self</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#159" name="159">0159</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">hasattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">ugc</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#160" name="160">0160</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">ugc</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><br />
<a class="lnum" href="#161" name="161">0161</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">elif</span>&#0160;<span class="name">hasattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">pvtec</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#162" name="162">0162</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">pvtec</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><br />
<a class="lnum" href="#163" name="163">0163</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">hvtec</span>&#0160;<span class="keyword">and</span>&#0160;<span class="name">hasattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">hvtec</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#164" name="164">0164</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">getattr</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">hvtec</span><span class="op">,</span>&#0160;<span class="name">name</span><span class="op">)</span><br />
<a class="lnum" href="#165" name="165">0165</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">raise</span>&#0160;<span class="name">AttributeError</span><br />
<a class="lnum" href="#166" name="166">0166</a><br />
<a class="lnum" href="#167" name="167">0167</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__str__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#168" name="168">0168</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s</span>&#0160;<span class="op">=</span>&#0160;<span class="op">[</span><span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">ugc</span><span class="op">)</span><span class="op">,</span>&#0160;<span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">pvtec</span><span class="op">)</span><span class="op">]</span><br />
<a class="lnum" href="#169" name="169">0169</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">if</span>&#0160;<span class="name">self</span><span class="op">.</span><span class="name">hvtec</span><span class="op">:</span><br />
<a class="lnum" href="#170" name="170">0170</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="name">s</span><span class="op">.</span><span class="name">append</span><span class="op">(</span><span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">.</span><span class="name">hvtec</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#171" name="171">0171</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="string">'\n'</span><span class="op">.</span><span class="name">join</span><span class="op">(</span><span class="name">s</span><span class="op">)</span><br />
<a class="lnum" href="#172" name="172">0172</a><br />
<a class="lnum" href="#173" name="173">0173</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">def</span>&#0160;<span class="name">__repr__</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">:</span><br />
<a class="lnum" href="#174" name="174">0174</a>&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;&#0160;<span class="keyword">return</span>&#0160;<span class="name">repr</span><span class="op">(</span><span class="name">str</span><span class="op">(</span><span class="name">self</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#175" name="175">0175</a><br />
<a class="lnum" href="#176" name="176">0176</a><br />
<a class="lnum" href="#177" name="177">0177</a><span class="keyword">if</span>&#0160;<span class="name">__name__</span>&#0160;<span class="op">==</span>&#0160;<span class="string">"__main__"</span><span class="op">:</span><br />
<a class="lnum" href="#178" name="178">0178</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">import</span>&#0160;<span class="name">sys</span><br />
<a class="lnum" href="#179" name="179">0179</a>&#0160;&#0160;&#0160;&#0160;<span class="name">prod</span>&#0160;<span class="op">=</span>&#0160;<span class="name">Product</span><span class="op">(</span><span class="name">file</span><span class="op">(</span><span class="name">sys</span><span class="op">.</span><span class="name">argv</span><span class="op">[</span><span class="number">1</span><span class="op">]</span><span class="op">,</span>&#0160;<span class="string">'r'</span><span class="op">)</span><span class="op">.</span><span class="name">read</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><br />
<a class="lnum" href="#180" name="180">0180</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">print</span>&#0160;<span class="name">prod</span><span class="op">.</span><span class="name">segments</span><span class="op">[</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><span class="op">.</span><span class="name">forecasts</span><br />
<a class="lnum" href="#181" name="181">0181</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">print</span>&#0160;<span class="name">prod</span><span class="op">.</span><span class="name">segments</span><span class="op">[</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><span class="op">.</span><span class="name">events</span><br />
<a class="lnum" href="#182" name="182">0182</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">print</span>&#0160;<span class="name">prod</span><span class="op">.</span><span class="name">segments</span><span class="op">[</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><span class="op">.</span><span class="name">headlines</span><br />
<a class="lnum" href="#183" name="183">0183</a>&#0160;&#0160;&#0160;&#0160;<span class="keyword">print</span>&#0160;<span class="name">prod</span><span class="op">.</span><span class="name">segments</span><span class="op">[</span><span class="op">-</span><span class="number">1</span><span class="op">]</span><span class="op">.</span><span class="name">hazard_keywords</span></code></div></body></html>